import React, { useEffect, useState } from "react"
import { IRouteComponentProps, history } from 'umi'
import styles from "./login.less"
import { Form, Input, Button, message } from 'antd';
import { RegistryUser } from "@/services/modules/login";
const Registry: React.FC<IRouteComponentProps> = (props) => {
    const error = (msg: string) => {
        message.error(`${msg}`);
    };
    async function onFinish(values: any) {
        //获取登录态
        RegistryUser(values.username, values.password, values.confirm).then(ok => {
            error('注册成功')
        })

    };

    return (
        <div className={styles.LoginBox}>
            <div className={styles.box}>
                <div>
                    图片
                </div>
                <div className={styles.from}>
                    <h3>访客注册</h3>
                    <div className={styles.formBox}>
                        <Form name="basic" onFinish={onFinish}>
                            <Form.Item
                                label="账户"
                                name="username"
                                rules={[{ required: true, message: '请输入用户名!' }]}
                            >
                                <Input placeholder="请输入用户名" />
                            </Form.Item>
                            <Form.Item
                                label="密码"
                                name="password"
                                rules={[{ required: true, message: '请输入密码!' }]}
                            >
                                <Input.Password placeholder="请输入密码" />
                            </Form.Item>
                            <Form.Item
                                label="确认"
                                name="confirm"
                                rules={[{ required: true, message: '请再次输入密码!' }]}
                            >
                                <Input.Password placeholder="请输入密码" />
                            </Form.Item>
                            <Form.Item >
                                <Button type="primary" htmlType="submit">
                                    注册
                                </Button>
                            </Form.Item>
                        </Form>
                    </div>
                    <div onClick={() => { history.replace('/login') }}>
                        Or 去登录
                    </div>
                </div>
            </div>
        </div>
    );
}
export default Registry